package com.siashan.toolkit.api.security.manager;

import com.siashan.toolkit.api.security.plugin.NonceStrVerifyPlugin;
import com.siashan.toolkit.api.security.plugin.TimeStampVerifyPlugin;
import com.siashan.toolkit.api.security.plugin.AppIdVerifyPlugin;
import lombok.Getter;
import lombok.Setter;
import org.springframework.stereotype.Component;

/**
 * 验签配置
 *
 * @author siashan
 * @since V1.0.1
 **/

@Setter
@Getter
@Component
public class RestCryptoManager {


    /**
     * appId校验插件
     */
    private AppIdVerifyPlugin appIdVerifyPlugin;
    /**
     * 时间戳校验插件
     */
    private TimeStampVerifyPlugin timeStampVerifyPlugin;
    /**
     * 随机数校验插件
     */
    private NonceStrVerifyPlugin nonceStrVerifyPlugin;


    /**
     * 注册APPID校验插件
     *
     * @param appIdVerifyPlugin    APPID校验插件
     * @return RestCryptoManager实体
     */
    public RestCryptoManager register(AppIdVerifyPlugin appIdVerifyPlugin) {
        this.appIdVerifyPlugin = appIdVerifyPlugin;
        return this;
    }


    /**
     * 注册时间戳校验插件
     *
     * @param timeStampVerifyPlugin   时间戳校验插件
     * @return RestCryptoManager实体
     */
    public RestCryptoManager register(TimeStampVerifyPlugin timeStampVerifyPlugin) {
        this.timeStampVerifyPlugin = timeStampVerifyPlugin;
        return this;
    }


    /**
     * 注册随机数校验插件
     * @param nonceStrVerifyPlugin   随机数校验插件
     * @return RestCryptoManager实体
     */
    public RestCryptoManager register(NonceStrVerifyPlugin nonceStrVerifyPlugin) {
        this.nonceStrVerifyPlugin = nonceStrVerifyPlugin;
        return this;
    }
}
